package com.txzhang.core;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * @author txzhang
 * @date 2021/1/5 17:06
 */
public class HandlerMappingChain implements HandlerMapping {

    static Map<String, Method> handlerData = new HashMap<>();

    @Override
    public Method getMapping(HttpServletRequest request) {
        return handlerData.get(getUri(request));
    }

    private String getUri(HttpServletRequest request) {
        return request.getRequestURI();
    }

    public void add(String uri, Method method) {
        handlerData.put(uri, method);
    }
}
